package common;

import java.util.List;
import java.util.Properties;

import dao.FileIO;
import dao.PropertyIO;

public class TrainController {
	private static final String propertyFilename = "conf/train.config";
	
	public void proceed(String trainFile, String modelFile) {
		Properties properties = PropertyIO.load(propertyFilename);
		
		ModelComposite model = new ModelComposite();
		model.initialize(properties);
		
		List<String> trainData = FileIO.readFile(trainFile);
		model.train(trainData);
		
		model.write(modelFile);
	}

	public static void main(String[] args) {
		if(args.length != 2) {
			System.out.println("USAGE: trainA.txt modelA.dat");
			return;
		}
		TrainController controller = new TrainController();
		controller.proceed(args[0], args[1]);
	}

}
